using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ShivamEMR.Model.Domain.CompanyDomain;
//using ShivamEMR.Web.Areas.Company.Models;
using ShivamEMR.Model.DataInterfaces.CompanyDataInterf;
using ShivamEMR.Model;

namespace ShivamEMR.Web.Areas.Company.Controllers
{   
    public class CompanyPictureController : Controller
    {
		private readonly ICompanyPictureRepository companypictureRepository;

		// If you are using Dependency Injection, you can delete the following constructor
        public CompanyPictureController()  
        {
            companypictureRepository = Registry.RepositoryFactory.GetCompanyPictureRepository();
        }

        public CompanyPictureController(ICompanyPictureRepository companypictureRepository)
        {
			this.companypictureRepository = companypictureRepository;
        }

        //
        // GET: /CompanyPicture/

        public ViewResult Index()
        {
            return View(companypictureRepository.All);
        }

        //
        // GET: /CompanyPicture/Details/5

        public ViewResult Details(System.Guid id)
        {
            return View(companypictureRepository.Find(id));
        }

        //
        // GET: /CompanyPicture/Create

        public ActionResult Create()
        {
            return View();
        } 

        //
        // POST: /CompanyPicture/Create

        [HttpPost]
        public ActionResult Create(CompanyPicture companypicture)
        {
            if (ModelState.IsValid) {
                companypictureRepository.Create(companypicture);
                companypictureRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }
        
        //
        // GET: /CompanyPicture/Edit/5
 
        public ActionResult Edit(System.Guid id)
        {
             return View(companypictureRepository.Find(id));
        }

        //
        // POST: /CompanyPicture/Edit/5

        [HttpPost]
        public ActionResult Edit(CompanyPicture companypicture)
        {
            if (ModelState.IsValid) {
                companypictureRepository.Update(companypicture);
                companypictureRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }

        //
        // GET: /CompanyPicture/Delete/5
 
        public ActionResult Delete(System.Guid id)
        {
            return View(companypictureRepository.Find(id));
        }

        //
        // POST: /CompanyPicture/Delete/5

        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(System.Guid id)
        {
            var cp = companypictureRepository.Find(id);
            companypictureRepository.Delete(cp);
            companypictureRepository.Save();

            return RedirectToAction("Index");
        }
    }
}

